<template>
  <div id="app">
    <div>
      <el-form label-width="70px">
        <el-form-item label="活动时间">
          <el-col :span="3">
            <el-date-picker v-model="form.date1" type="month" placeholder="选择日期" style="width: 100%;" />
          </el-col>
          <el-col :span="3">
            <el-date-picker v-model="form.date2" type="month" placeholder="选择日期" style="width: 100%;" />
          </el-col>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">确定</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="statement-detail-exportbtn">
      <button
        class="veui-button"
        @click="exportExcel"
      >
        <span>导出</span>
      </button>
    </div>

  </div>
</template>

<script>
import { demoApi } from './demo'
export default {
  data() {
    return {
      form: {
        date1: '',
        date2: ''
      }
    }
  },
  methods: {
    onSubmit() {
      console.log(this.form)
    },
    exportMethod(data) {
      demoApi().then((res) => {
        const link = document.createElement('a')
        const blob = new Blob([res.data], { type: 'application/x-excel' })
        link.style.display = 'none'
        link.href = URL.createObjectURL(blob)
        link.download = data.fileName
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link)
      })
    },
    exportExcel() {
      const data = {
        fileName: ' 结算单详情.xlsx'
      }
      this.exportMethod(data)
    }
  }
}
</script>
